<?php

namespace app\airobot\controller;

use app\airobot\CommonLogic;
use app\airobot\model\OriginBanner;
use think\admin\Controller;

/**
 * 超管系统-Banner管理
 * Class Banner
 * @package app\airobot\controller
 */
class Banner extends Controller
{
    private $table = 'banner';
    public $commonLogic;

    /**
     * Banner列表
     * @auth true
     */
    public function index()
    {
        $this->commonLogic = new CommonLogic();
        $this->title = 'Banner';
        $query = $this->_query($this->table);
        $where = [];
        $query->where($where);
        $query->order('id desc')->page();
    }


    protected function _index_page_filter(array &$data)
    {

    }

    /**
     * 添加数据字典
     * @auth true
     */
    public function add()
    {
        if ($this->request->isPost()) {
            $data = $this->request->post();
            $createData = [];
            $createData["sort"] = $data["sort"];
            $createData["image"] = $data["image"];
            $bannerModel = new \app\airobot\model\Banner();
            $bannerModel->createInfo($createData);
            $this->success("保存成功！");
        } else {
            OriginBanner::mForm('form');
        }
    }

    /**
     * 编辑数据字典
     * @auth true
     */
    public function edit()
    {
        $bannerModel = new \app\airobot\model\Banner();
        $this->vo = $bannerModel->queryInfo(["id" => $_GET["id"]]);
        OriginBanner::mForm('form');
    }

    /**
     * 删除
     * @auth true
     */
    public function remove()
    {
        $this->_delete($this->table, 'id');
    }
}